/*
 * packet_def.c
 *
 *  Created on: 08/11/2012
 *      Author: julian
 */

#include "packet_def.h"
#include <stdio.h>

//----------------------tramas que se envían

void print_tx_64(xbee_TxFrame64_t packet64) {
    uint8_t i=0;
    printf("\noutput TX64:");
    printf("\nlen: %d ", packet64.dataSize);
    printf("dst64: %#X", packet64.destinationAddress >> 32);
    printf("%X ", packet64.destinationAddress);
    printf("fid: %d ", packet64.frameId);
    printf("opt: %X ", packet64.options);
    printf("data: ");
    for (i = 0; i < packet64.dataSize; i++) {
        printf("%X ", packet64.data[i]);
    }
}

void print_tx_16(xbee_TxFrame16_t packet16) {
    uint8_t i=0;
    printf("\nlen: %d ", packet16.dataSize);
    printf("dst16: %04X ", packet16.destinationAddress);
    printf("fid: %d ", packet16.frameId);
    printf("opt: %X ", packet16.options);
    printf("data: ");
    for (i = 0; i < packet16.dataSize; i++) {
        printf("%X ", packet16.data[i]);
    }
}

void print_AT_remote_request(xbee_AtRemote_t at_request) {
    uint8_t i=0;
    printf("\n ATRemote_request: frameid: %X ", at_request.frameId);
    printf("addr64: %#X", at_request.destinationAddress64 >> 32);
    printf("%X ", at_request.destinationAddress64);
    printf("addr16: %04X ", at_request.destinationAddress16);
    printf("command: %C", at_request.command[0]);
    printf("%C ", at_request.command[1]);
    printf("opt: %X ", at_request.options);
    printf("vSize: %d ", at_request.valueSize);
    printf("value: ");
    for (i = 0; i < at_request.valueSize; i++) {
        printf("%X ", at_request.value[i]);
    }
}

void print_AT_request(xbee_AtCommand_t command) {
    uint8_t i=0;
    printf("\n frameid: %X ", command.frameId);
    printf("command: %C", command.command[0]);
    printf("%C ", command.command[1]);
    printf("pSize: %d ", command.parameterSize);
    printf("value: ");
    for (i = 0; i < command.parameterSize; i++) {
        printf("%X ", command.parameter[i]);
    }

}

//----------------------tramas que se reciben

void print_AT_remote_response(xbee_AtRemoteResponse_t at_remoteresponse) {
    uint8_t i=0;
    printf("\n fid: %X ", at_remoteresponse.frameId);
    printf("src64: %#X", at_remoteresponse.sourceAddress64 >> 32);
    printf("%X ", at_remoteresponse.sourceAddress64);
    printf("src16: %04X ", at_remoteresponse.sourceAddress16);
    printf("command: %c", at_remoteresponse.command[0]);
    printf("%c ", at_remoteresponse.command[1]);
    printf("status: %X ", at_remoteresponse.status);
    printf("vSize: %d ", at_remoteresponse.valueSize);
    printf("value: ");
    for (i = 0; i < at_remoteresponse.valueSize; i++) {
        printf("%c", at_remoteresponse.value[i]);
    }
}

void print_AT_response(xbee_AtCommandResponse_t at_response) {
    uint8_t i=0;
    printf("\n fid: %X ", at_response.frameId);
    printf("command: %c", at_response.command[0]);
    printf("%c ", at_response.command[1]);
    printf("status: %X ", at_response.status);
    printf("vSize: %d ", at_response.valueSize);
    printf("value: ");
    for (i = 0; i < at_response.valueSize; i++) {
        printf("%X", at_response.value[i]);
    }
}


void print_rx_64(xbee_RxFrame64_t packet64) {
    uint8_t i=0;
    printf("\ninput RX64:");
    printf("\nlen: %d ", packet64.dataSize);
    printf("src64: %#X", packet64.sourceAddress >> 32);
    printf("%X ", packet64.sourceAddress);
    printf("rssi: -%ddBm ", packet64.RSSI);
    printf("opt: %X ", packet64.options);
    printf("data: ");
    for (i = 0; i < packet64.dataSize; i++) {
        printf("%X ", packet64.data[i]);
    }
}

void print_rx_16(xbee_RxFrame16_t packet16){
    uint8_t i=0;
    printf("\ninput RX16.len: %d, src: %04X, rssi: -%ddBm, opt: %X, data: ",
            packet16.dataSize, packet16.sourceAddress, packet16.RSSI,
            packet16.options);
    for (i = 0; i < packet16.dataSize; i++) {
        printf("%X ", packet16.data[i]);
    }
}

void print_tx_status(xbee_TxStatus_t tx_response){
    printf("\nTX_response:");
    printf("\nfid: %d ", tx_response.frameId);
    printf("status %d.\n", tx_response.status);
}
